package com.zwcl.glass.tools.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zwcl.glass.tools.entity.PaperConclusion;
import com.zwcl.glass.tools.mapper.PaperConclusionMapper;
import com.zwcl.glass.tools.service.PaperConclusionService;
import com.zwcl.common.mybatis.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 规则得出结论，先默认为相与 服务实现类
 * </p>
 *
 * @author xieyongping
 * @since 2021-01-07
 */
@Service
public class PaperConclusionServiceImpl extends BaseServiceImpl<PaperConclusionMapper, PaperConclusion> implements PaperConclusionService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean savePaperConclusion(PaperConclusion paperConclusion) throws Exception {
        return super.save(paperConclusion);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updatePaperConclusion(PaperConclusion paperConclusion) throws Exception {
        return super.updateById(paperConclusion);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deletePaperConclusion(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public List<PaperConclusion> getPaperConclusionList(Integer paperId) {
        QueryWrapper<PaperConclusion> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(PaperConclusion::getPaperId,paperId).eq(PaperConclusion::getIsValid,1);
        return this.list(queryWrapper);
    }

    @Override
    public List<PaperConclusion> getPaperConclusionListByCode(String paperCode) {
        QueryWrapper<PaperConclusion> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(PaperConclusion::getPaperCode,paperCode).eq(PaperConclusion::getIsValid,1).orderByAsc(PaperConclusion::getId);
        return this.list(queryWrapper);
    }

}
